home *** CD-ROM | disk | FTP | other *** search
/ LG Super CD / LG Super CD.iso / bitpim / bitpim-0.62-setup.exe / {app} / bitpim.exe / copy_reg.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-11-06  |  5.0 KB  |  156 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.3)
  3.  
  4. from types import ClassType as _ClassType
  5. __all__ = [
  6.     'pickle',
  7.     'constructor',
  8.     'add_extension',
  9.     'remove_extension',
  10.     'clear_extension_cache']
  11. dispatch_table = { }
  12.  
  13. def pickle(ob_type, pickle_function, constructor_ob = None):
  14.     if type(ob_type) is _ClassType:
  15.         raise TypeError('copy_reg is not intended for use with classes')
  16.     
  17.     if not callable(pickle_function):
  18.         raise TypeError('reduction functions must be callable')
  19.     
  20.     dispatch_table[ob_type] = pickle_function
  21.     if constructor_ob is not None:
  22.         constructor(constructor_ob)
  23.     
  24.  
  25.  
  26. def constructor(object):
  27.     if not callable(object):
  28.         raise TypeError('constructors must be callable')
  29.     
  30.  
  31.  
  32. try:
  33.     complex
  34. except NameError:
  35.     pass
  36.  
  37.  
  38. def pickle_complex(c):
  39.     return (complex, (c.real, c.imag))
  40.  
  41. pickle(complex, pickle_complex, complex)
  42.  
  43. def _reconstructor(cls, base, state):
  44.     if base is object:
  45.         obj = object.__new__(cls)
  46.     else:
  47.         obj = base.__new__(cls, state)
  48.         base.__init__(obj, state)
  49.     return obj
  50.  
  51. _HEAPTYPE = 1 << 9
  52.  
  53. def _reduce_ex(self, proto):
  54.     for base in self.__class__.__mro__:
  55.         if hasattr(base, '__flags__') and not (base.__flags__ & _HEAPTYPE):
  56.             break
  57.             continue
  58.     else:
  59.         base = object
  60.     if base is object:
  61.         state = None
  62.     elif base is self.__class__:
  63.         raise TypeError, "can't pickle %s objects" % base.__name__
  64.     
  65.     state = base(self)
  66.     args = (self.__class__, base, state)
  67.     
  68.     try:
  69.         getstate = self.__getstate__
  70.     except AttributeError:
  71.         if getattr(self, '__slots__', None):
  72.             raise TypeError('a class that defines __slots__ without defining __getstate__ cannot be pickled')
  73.         
  74.         
  75.         try:
  76.             dict = self.__dict__
  77.         except AttributeError:
  78.             dict = None
  79.         except:
  80.             None<EXCEPTION MATCH>AttributeError
  81.         
  82.  
  83.         None<EXCEPTION MATCH>AttributeError
  84.  
  85.     dict = getstate()
  86.     if dict:
  87.         return (_reconstructor, args, dict)
  88.     else:
  89.         return (_reconstructor, args)
  90.  
  91.  
  92. def __newobj__(cls, *args):
  93.     return cls.__new__(cls, *args)
  94.  
  95.  
  96. def _slotnames(cls):
  97.     names = cls.__dict__.get('__slotnames__')
  98.     if names is not None:
  99.         return names
  100.     
  101.     names = []
  102.     if not hasattr(cls, '__slots__'):
  103.         pass
  104.     else:
  105.         for c in cls.__mro__:
  106.             if '__slots__' in c.__dict__:
  107.                 names += []
  108.                 continue
  109.         
  110.     
  111.     try:
  112.         cls.__slotnames__ = names
  113.     except:
  114.         pass
  115.  
  116.     return names
  117.  
  118. _extension_registry = { }
  119. _inverted_registry = { }
  120. _extension_cache = { }
  121.  
  122. def add_extension(module, name, code):
  123.     code = int(code)
  124.     if not None if code <= code else code <= 2147483647:
  125.         raise ValueError, 'code out of range'
  126.     
  127.     key = (module, name)
  128.     if _extension_registry.get(key) == code and _inverted_registry.get(code) == key:
  129.         return None
  130.     
  131.     if key in _extension_registry:
  132.         raise ValueError('key %s is already registered with code %s' % (key, _extension_registry[key]))
  133.     
  134.     if code in _inverted_registry:
  135.         raise ValueError('code %s is already in use for key %s' % (code, _inverted_registry[code]))
  136.     
  137.     _extension_registry[key] = code
  138.     _inverted_registry[code] = key
  139.  
  140.  
  141. def remove_extension(module, name, code):
  142.     key = (module, name)
  143.     if _extension_registry.get(key) != code or _inverted_registry.get(code) != key:
  144.         raise ValueError('key %s is not registered with code %s' % (key, code))
  145.     
  146.     del _extension_registry[key]
  147.     del _inverted_registry[code]
  148.     if code in _extension_cache:
  149.         del _extension_cache[code]
  150.     
  151.  
  152.  
  153. def clear_extension_cache():
  154.     _extension_cache.clear()
  155.  
  156.